/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef __GLControls_hpp_
#define __GLControls_hpp_

#include <string>
#include <GL/glut.h>
#include "picking.hpp"


class CGLButton;

class CButtonCallback
{
  public: 
    virtual void OnButtonEvent(CGLButton* button){}
};

class CGLButton : public CGLPickable, public CGLPickCallback
{
  public:
    CGLButton();
    
    void SetPosition(const float x, const float y, const float z);
    
    void GetPosition(float &x, float &y, float &z);
    
    void SetCallback(CButtonCallback *callback);
    
    CButtonCallback* GetCallback();
    
    void Enable(bool enable);
    
    bool IsEnabled();
        
    /* Pickable stuff */
    
    void Draw();
    
    void OnFocus(TGLPickEvent event);
    
    void OnFocusLost(TGLPickEvent event);
    
    void OnPick(TGLPickEvent event);
    
    void OnRelease(TGLPickEvent event);
  
  protected:
    virtual void DrawPickable(){};
    
    virtual void DrawUp(){};
    
    virtual void DrawDown(){};
    
    virtual void DrawFocused(){};
    
    virtual void DrawDisabled(){};
    
    
    CButtonCallback *buttonCallback;
    float x,y,z;
    bool pressed;
    bool focused;
    
  private:
    bool enabled;
    
};

class C2DTextButton : public CGLButton
{
  public:
    C2DTextButton();
    
    void SetText(std::string text);
  
  protected:
    void DrawPickable();
    
    void DrawUp();
    
    void DrawDown();
    
    void DrawFocused();
    
    void DrawDisabled();
    
  private:
    float width;
    float height;
    std::string text;
    
    
    void drawtext();
};

#endif
